package com.hjxr.sysadmin.zsj.controller;

import java.util.List;

import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.controller.BaseController;
import com.hjxr.sysadmin.web.page.TableDataInfo;
import com.hjxr.sysadmin.zsj.domain.CheckMessageZ;
import com.hjxr.sysadmin.zsj.service.ICheckMessageZService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;


/**
 * 招商意向需求Controller
 *
 * @author hjxr
 * @date 2021-03-22
 */
@Api("招商意向需求")
@RestController
@RequestMapping("/message")
public class CheckMessageZController extends BaseController
{
    @Autowired
    private ICheckMessageZService checkMessageZService;

    /**
     * 查询招商意向需求列表
     */
    @ApiOperation("查询招商意向需求列表")
    @GetMapping("/list")
    public TableDataInfo list(CheckMessageZ checkMessageZ)
    {
        startPage();
        List<CheckMessageZ> list = checkMessageZService.selectCheckMessageZList(checkMessageZ);
        return getDataTable(list);
    }

    /**
     * 导出招商意向需求列表
     */
    @ApiOperation("导出招商意向需求列表")
    @Log(title = "招商意向需求", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CheckMessageZ checkMessageZ)
    {
        List<CheckMessageZ> list = checkMessageZService.selectCheckMessageZList(checkMessageZ);
        ExcelUtil<CheckMessageZ> util = new ExcelUtil<CheckMessageZ>(CheckMessageZ.class);
        return util.exportExcel(list, "z");
    }

    /**
     * 获取招商意向需求详细信息
     */
    @ApiOperation("获取招商意向需求详细信息")
    @GetMapping(value = "/{checkCid}")
    public AjaxResult getInfo(@PathVariable("checkCid") Long checkCid)
    {
        return AjaxResult.success(checkMessageZService.selectCheckMessageZById(checkCid));
    }

    /**
     * 新增招商意向需求
     */
    @ApiOperation("新增招商意向需求")
    @Log(title = "招商意向需求", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CheckMessageZ checkMessageZ)
    {
        return toAjax(checkMessageZService.insertCheckMessageZ(checkMessageZ));
    }

    /**
     * 修改招商意向需求
     */
    @ApiOperation("修改招商意向需求")
    @Log(title = "招商意向需求", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CheckMessageZ checkMessageZ)
    {
        return toAjax(checkMessageZService.updateCheckMessageZ(checkMessageZ));
    }

    /**
     * 删除招商意向需求
     *
     */
    @ApiOperation("删除招商意向需求")
    @Log(title = "招商意向需求", businessType = BusinessType.DELETE)
	@DeleteMapping("/{checkCids}")
    public AjaxResult remove(@PathVariable Long[] checkCids)
    {
        return toAjax(checkMessageZService.deleteCheckMessageZByIds(checkCids));
    }

    /**
     * 查询招商意向需求列表
     */
    @ApiOperation("通过企业名称查询需求")
    @GetMapping("/cmlist/{companyName}")
    public TableDataInfo cmlist(@PathVariable("companyName")String companyName)
    {
        startPage();
        List<CheckMessageZ> list = checkMessageZService.cmlist(companyName);
        return getDataTable(list);
    }
}
